package com.github.llyb120.qiuya.error;

import com.github.llyb120.qiuya.type.QType;

public class QTypeErrorException extends RuntimeException {

    private short type;
    private QType shouldBe;

    public QTypeErrorException(short type, QType shouldBe) {
        this.type = type;
        this.shouldBe = shouldBe;
    }

    @Override
    public String getMessage() {
        QType[] items = QType.class.getEnumConstants();
        for (QType item : items) {
            if(item.getValue() == type){
                return String.format("type should be %s, received %d", shouldBe, item.getValue());
            }
        }
        return String.format("type should be %s, received %s", shouldBe, "unknown");
    }
}
